home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / cool / ge_cool.lha / GE_COOL2.1 / man / oldman3 / Bit_Set.3T < prev    next >
Text File  |  1992-06-26  |  13KB  |  439 lines

  1. .TH BIT_SET
  2. .SH NAME
  3. Bit_Set  Efficient, dynamic bit sets
  4. .SH SYNOPSIS
  5. #include <cool/Bit_Set.h>
  6. .SH DESCRIPTION
  7. The
  8.  Bit_Set 
  9. class is publicly derived from the 
  10.   
  11. class and implements 
  12. efficient bit sets. These bits are stored in an arbitrary-length vector of 
  13. bytes (unsigned 
  14.  char ) 
  15. large enough to represent the specified number of 
  16. elements. A bit set is indexed by integer values: Zero represents the first 
  17. bit, one the second, two the third, and so on with each integer value actually 
  18. indicating the zero-relative bit position in the bit vector. Elements can be 
  19. integers, enum values, constant symbols from the enumeration package, or any 
  20. other type of object or expression that results in an integral value. All 
  21. operations involving bit shifting are performed in byte increments, giving the 
  22. most efficient operation on common hardware architectures.
  23. .SH Base Classes
  24. None
  25. .SH Friend Classes
  26. None
  27. .SH Public Constructors
  28. .TP
  29.  Bit_Set ();
  30. Allocates a bit set of the default size (1 byte).
  31. .TP
  32. \f3Bit_Set (unsigned int \f2number\f3);\f1
  33. Allocates a bit set with at least enough storage for
  34.  number 
  35. elements.
  36. .TP
  37. \f3Bit_Set (const Bit_Set& \f2bs\f3);\f1
  38. Duplicates the size and elements of another bit set object
  39.  bs .
  40. .SH Member Functions
  41. .TP
  42.  inline int capacity () const;
  43. Returns the maximum number of elements that the bit set can hold.
  44. .TP
  45.  void clear ();
  46. Removes all elements from the bit set and adjusts the appropriate counts.
  47. .TP
  48.  inline Bit_Set_state& current_position () const;
  49. Returns the state information associated with the current position. This 
  50. function should be used with the \f3Iterator<Type>\f1 class to save and restore the 
  51. current position, thus facilitating multiple iterators over an instance of bit 
  52. set.
  53. .TP
  54. \f3Boolean find (unsigned int \f2n\f3);\f1
  55. Searches the bit set for the \f2nt\f1h zero-relative bit. If the bit is set, this 
  56. function updates the current position and returns 
  57.  
  58.  TRUE ; 
  59. otherwise, this 
  60. function invalidates the current position and returns 
  61.  
  62.  FALSE . 
  63. If 
  64.  n 
  65. is out of 
  66. range, an 
  67.  \f3\f3Error\f1\f1 
  68. exception is raised.
  69. .TP
  70.  inline Boolean is_empty () const;
  71. Returns 
  72.  
  73.  TRUE 
  74. if the bit set contains no elements; otherwise, this function 
  75. returns 
  76.  
  77.  FALSE .
  78. .TP
  79.  int length () const;
  80. Returns the number of elements in the bit set.
  81. .TP
  82.  Boolean next ();
  83. Advances the current position pointer to the next element in the bit set and 
  84. returns 
  85.  
  86.  TRUE . 
  87. If the current position is invalid, this function advances to the 
  88. first element and returns 
  89.  
  90.  TRUE . 
  91. If advancing past the last element in the bit 
  92. set, this function invalidates the current position and returns 
  93.  
  94.  FALSE .
  95.  
  96. .TP
  97. \f3Boolean next_difference (const Bit_Set& \f2bs\f3);\f1
  98. Determines the next element in the difference of the set object and 
  99.  bs . 
  100. This 
  101. function sets the current position in the set object to that element and 
  102. returns 
  103.  
  104.  TRUE . 
  105. If no more elements are in the different, this function 
  106. invalidates the current position and returns
  107.  
  108.  FALSE .
  109. .TP
  110. \f3Boolean next_intersection (const Bit_Set& \f2bs\f3);\f1
  111. Determines the next element in the intersection of the set object and
  112.  bs . 
  113. This 
  114. function sets the current position of the set object to that element and 
  115. returns 
  116.  
  117.  TRUE . 
  118. If no more elements are in the intersection, this function 
  119. invalidates the current position and returns 
  120.  
  121.  FALSE .
  122. .TP
  123. \f3Boolean next_union (const Bit_Set& \f2bs\f3);\f1
  124. Determines the next element in the union of the set object and 
  125.  bs . 
  126. This 
  127. function sets the current position of the set object to that element and 
  128. returns 
  129.  
  130.  TRUE . 
  131. If no more elements are in the union, this function invalidates 
  132. the current position and returns 
  133.  
  134.  FALSE .
  135. .TP
  136. \f3Boolean next_xor (const Bit_Set& \f2bs\f3);\f1
  137. Determines the next element in the exclusive-or of the set object and 
  138.  bs . 
  139. This 
  140. function sets the current position of the set object to that element and 
  141. returns 
  142.  
  143.  TRUE . 
  144. If no more elements are in the exclusive-or, this function 
  145. invalidates the current position and returns
  146.  
  147.  FALSE .
  148. .TP
  149.  Bit_Set operator\- ();
  150. Overloads the unary minus operator to return the complement bit set.
  151. .TP
  152. \f3Bit_Set operator- (const Bit_Set& \f2bs\f3);\f1
  153. Determines the logical difference of the set object and 
  154.  bs 
  155. and returns the 
  156. result. This function invalidates the current position of the set object.
  157. .TP
  158.  inline Bit_Set operator~ ();
  159. Returns the complement of a bit set.
  160. .TP
  161. \f3Bit_Set operator^ (const Bit_Set& \f2bs\f3);\f1
  162. Determines the logical exclusive-or of the set object and 
  163.  bs 
  164. and returns the 
  165. result. This function invalidates the current position of the set object.
  166. .TP
  167. \f3Bit_Set operator& (const Bit_Set& \f2bs\f3);\f1
  168. Determines the logical intersection of the set object and 
  169.  bs 
  170. and returns the 
  171. result. This function invalidates the current position of the set object.
  172. .TP
  173. \f3Bit_Set operator| (const Bit_Set& \f2bs\f3);\f1
  174. Determines the logical union of the set object and 
  175.  bs 
  176. and returns the result. 
  177. This function invalidates the current position of the set object.
  178. .TP
  179. \f3Bit_Set& operator= (const Bit_Set& \f2bs\f3);\f1
  180. Duplicates the size and elements of another bit set. This function invalidates 
  181. the current position of the set object and returns a reference to the updated 
  182. object.
  183. .TP
  184. \f3Bit_Set& operator\-= (const Bit_Set& \f2bs\f3);\f1
  185. Determines the logical difference of the set object and 
  186.  bs 
  187. and modifies the 
  188. source with the result. This function returns a reference to the modified bit 
  189. set and invalidates the current position of the set object.
  190. .TP
  191. \f3Bit_Set& operator^= (const Bit_Set& \f2bs\f3);\f1
  192. Determines the logical exclusive-or of the set object and 
  193.  bs 
  194. and modifies the 
  195. source with the result. This function returns a reference to the modified bit 
  196. set and invalidates the current position of the set object.
  197.  
  198. .TP
  199. \f3Bit_Set& operator&= (const Bit_Set& \f2bs\f3);\f1
  200. Determines the logical intersection of the set object and 
  201.  bs 
  202. and modifies the 
  203. source with the result. This function returns a reference to the modified bit 
  204. set and invalidates the current position of the set object.
  205. .TP
  206. \f3Bit_Set& operator|\^= (const Bit_Set& \f2bs\f3);\f1
  207. Determines the logical union of the set object and 
  208.  bs 
  209. and modifies the source 
  210. with the result. This function returns a reference to the modified bit set and 
  211. invalidates the current position of the set object.
  212. .TP
  213. \f3Boolean operator== (const Bit_Set& \f2bs\f3) const;\f1
  214. Overloads the equality operator for the 
  215.  Bit_Set 
  216. class. This function returns
  217.  
  218.  TRUE 
  219. if the sets have an equal number of elements with the same values; 
  220. otherwise, this function returns 
  221.  
  222.  FALSE .
  223. .TP
  224. \f3inline Boolean operator!= (const Bit_Set& \f2bs\f3) const;\f1
  225. Overloads the inequality operator for the 
  226.  Bit_Set 
  227. class. This function returns 
  228.  
  229.  TRUE 
  230. if the sets have an unequal number of elements or unequal values 
  231. otherwise, this function returns 
  232.  
  233.  FALSE .
  234. .TP
  235. \f3inline Boolean operator[\^] (int \f2n\f3) const;\f1
  236. Returns 
  237.  
  238.  TRUE 
  239. or 
  240.  
  241.  FALSE 
  242. to indicate the setting of the zero-relative \f2n\f1th bit. If 
  243. the index is out of range, an 
  244.  \f3\f3Error\f1\f1 
  245. exception is raised.
  246. .TP
  247.  Boolean prev ();
  248. Moves the current position pointer to the previous element in the bit set and 
  249. returns 
  250.  
  251.  TRUE . 
  252. If the current position is invalid, this function moves to the 
  253. last element and returns 
  254.  
  255.  TRUE . 
  256. If moving to the previous element passes the 
  257. first element in the bit set, this function invalidates the current position 
  258. and returns 
  259.  
  260.  FALSE .
  261. .TP
  262. \f3Boolean put (int \f2n\f3);\f1
  263. Adds the zero-relative \f2n\f1th element to the bit set. If the bit vector is not 
  264. large enough and it can grow, this function allocates enough storage, copies 
  265. the old bit set elements, updates the current position, and returns 
  266.  
  267.  TRUE ; 
  268. otherwise, this function returns 
  269.  
  270.  FALSE . 
  271. If the index is out of range, an 
  272.  \f3\f3Error\f1\f1 
  273. exception is raised.
  274. .TP
  275. \f3Boolean put (int \f2start\f3, int \f2end\f3);\f1
  276. Adds the specified range of elements (inclusive) to the bit set by setting the 
  277. appropriate zero-relative bits. If the bit vector is not large enough and it 
  278. can grow, this function allocates enough storage, copies the old bit set 
  279. elements, updates the current position, and returns 
  280.  
  281.  TRUE ; 
  282. otherwise, this 
  283. function returns 
  284.  
  285.  FALSE . 
  286. If the \f2start\f1 or \f2end\f1 are out of range, an 
  287.  \f3\f3Error\f1\f1 
  288. exception is raised.
  289. .TP
  290.  Boolean remove ();
  291. This function removes the element at the current position, sets the current 
  292. position to the element immediately following the element removed (if not at 
  293. the end of the vector), and returns 
  294.  
  295.  TRUE . 
  296. If the element is at the end of the 
  297. bit vector, this function removes the element, invalidates the current 
  298. position, and returns 
  299.  
  300.  TRUE . 
  301. Otherwise, this function invalidates the current 
  302. position and returns 
  303.  
  304.  FALSE . 
  305. If the current position is invalid, an 
  306.  \f3\f3Error\f1\f1 
  307. exception is raised and this function returns 
  308.  
  309.  FALSE . 
  310. .TP
  311. \f3Boolean remove (int \f2n\f3);\f1
  312. Searches for the zero-relative \f2n\f1th element. If the element is found, this 
  313. function removes the element, sets the current position to the element 
  314. immediately following the element removed, and returns 
  315.  
  316.  TRUE . 
  317. If the element is 
  318. found but at the end of the bit vector, this function removes the element, 
  319. invalidates the current position, and returns 
  320.  
  321.  TRUE . 
  322. Otherwise, this function 
  323. returns 
  324.  
  325.  FALSE . 
  326. If the index is out of range, an 
  327.  \f3\f3Error\f1\f1
  328. exception is raised.
  329. .TP
  330. \f3Boolean remove (int \f2start\f3, int \f2end\f3);\f1
  331. Searches for the specified range of elements. If the range is found, this 
  332. function removes the range of elements, sets the current position to the 
  333. starting element position, and returns 
  334.  
  335.  TRUE . 
  336. Otherwise, this function returns 
  337.  
  338.  FALSE . 
  339. If either index is out of range, an 
  340.  \f3\f3Error\f1\f1 
  341. exception is raised.
  342. .TP
  343.  inline void reset ();
  344. Invalidates the current position.
  345. .TP
  346. \f3resize (int \f2number);\f1
  347. Resizes the bit set for at least 
  348.  number 
  349. elements. This function invalidates the 
  350. current position.
  351. .TP
  352. \f3Boolean search (const Bit_Set& \f2bs\f3) const;\f1
  353. Determines if 
  354.  bs 
  355. is a subset of the bit set object. If found, this function  
  356. returns 
  357.  
  358.  TRUE ; 
  359. otherwise, this function returns 
  360.  
  361.  FALSE .
  362. .TP
  363. \f3inline void set_alloc_size (int \f2number\f3);\f1
  364. Sets the allocation growth size to
  365.  number 
  366. of bytes. The growth allocation size 
  367. is used when the growth ratio is zero. Default allocation growth size is four 
  368. bytes. 
  369. .TP
  370. \f3inline void set_difference (const Bit_Set& \f2bs\f3);\f1
  371. Determines the logical difference of
  372.  bs 
  373. and the bit set object, modifing the 
  374. source with the result. This function invalidates the current position in the 
  375. bit set object.
  376. .TP
  377. \f3inline void set_growth_ratio (float \f2ratio\f3);\f1
  378. Updates the growth ratio for this instance of a bit set to
  379.   ratio. 
  380. When a bit 
  381. set needs to grow, the current size is multiplied by the ratio to determine the 
  382. new size. If 
  383.  ratio 
  384. is negative, and 
  385.  \f3\f3Error\f1\f1 
  386. exception is raised.
  387. .TP
  388. \f3inline void set_intersection (const Bit_Set& \f2bs\f3);\f1
  389. Determines the logical intersection of
  390.  bs 
  391. and the bit set object, modifing the 
  392. source with the result. This function invalidates the current position of the 
  393. bit set object.
  394. .TP
  395. \f3inline void set_union (const Bit_Set& \f2bs\f3);\f1
  396. Determines the logical union of
  397.  bs 
  398. and the bit set object, modifing the source 
  399. with the result. This function invalidates the current position of the bit set 
  400. object.
  401. .TP
  402. \f3inline void set_xor (const Bit_Set& \f2bs\f3);\f1
  403. Determines the logical exclusive-or of
  404.  bs 
  405. and the bit set object, modifing the 
  406. source with the result. This function invalidates the current position of the 
  407. bit set object.
  408. .TP
  409.  inline int value ();
  410. Returns the value (zero-relative bit position) of the bit at the current 
  411. position. If the current position is invalid, an
  412.  \f3\f3Error\f1\f1 
  413. exception is raised.
  414. .SH Friend Functions
  415. .TP
  416. \f3friend ostream& operator<< (ostream& \f2os\f3, const \f2Bit_Set& bs\f3);\f1
  417. Overloads the output operator for a reference to a 
  418.  Bit_Set 
  419. object to provide a 
  420. formatted output capability for the class.
  421. .TP
  422. \f3inline friend ostream& operator<< (ostream& \f2os\f3, const \f2Bit_Set* bs\f3);\f1
  423. Overloads the output operator for a reference to a
  424.  Bit_Set 
  425. object to provide a 
  426. formatted output capability for the class.
  427. .SH COPYRIGHT
  428.  
  429. Copyright (C) 1991 Texas Instruments Incorporated.
  430.  
  431. Permission is granted to any individual or institution to use, copy, modify,
  432. and distribute this software, provided that this complete copyright and
  433. permission notice is maintained, intact, in all copies and supporting
  434. documentation.
  435.  
  436. Texas Instruments Incorporated provides this software "as is" without
  437. express or implied warranty.
  438.  
  439.